package com.wzc.hc.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wzc.hc.entity.po.Facility;
import com.wzc.hc.entity.po.Owner;
import com.wzc.hc.entity.po.Reservation;
import com.wzc.hc.entity.resp.Result;
import com.wzc.hc.mapper.FacilityMapper;
import com.wzc.hc.mapper.ReservationMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/*
  @author:33691
  @date:2025/3/5 16:35
*/
@RestController
@RequestMapping("/owner")
@Slf4j
public class FacilityReservationController {

    //游泳馆
    @Autowired
    ReservationMapper reservation;


    //会议室
    @Autowired
    FacilityMapper facility;

    //分页查询游泳馆
    @GetMapping("/getreservation")
    public Result<IPage<Reservation>> getReservation(
            @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
            @RequestParam(value = "pageSize", defaultValue = "5") int pageSize){
        Page<Reservation> Page = new Page<>(pageNum, pageSize);
        IPage<Reservation> pageResult = reservation.selectPage(Page, null);
        return Result.ok(pageResult);
    }

    //分页查询会议室
    @GetMapping("/getfacility")
    public Result<IPage<Facility>> getFacility(
            @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
            @RequestParam(value = "pageSize", defaultValue = "5") int pageSize){
        Page<Facility> Page = new Page<>(pageNum, pageSize);
        IPage<Facility> pageResult = facility.selectPage(Page, null);
        return Result.ok(pageResult);
    }
}
